<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
</body>
<script>
  
  const mapTree = item => {
    const haveChildren = Array.isArray(item.array) && item.array.length > 0;
    return {
      key : item.name,
      children:haveChildren ? item.array.map(i => mapTree(i)) : [],
    }
  };
  const treeData = [     
    {
      name:'张三',
      array:[{
        name:'李四',
        array:[{
          name:'王五'
        }]
      }]
    },
    {
      name:'赵六'
    }
  ]
  console.log(treeData.map(item => mapTree(item)))
</script>
</html>